import Vue from 'vue'
import Router from 'vue-router'
const Login = () => import('./views/Login.vue')
Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [{ path: '/login', component: Login }]
})

router.beforeEach((to, from, next) => {
  const token = sessionStorage.getItem('token')
  if (!token && to.path !== '/login') {
    return next('/login')
  }
  next()
})

export default router
